package com.martin.study;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Component
@EnableTransactionManagement
public class LazyBeanDemo {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(LazyBeanDemo.class);
		InterfaceDemo interfaceDemo = (InterfaceDemo) context.getBean("javaBeanDemo");
		interfaceDemo.say();
	}

	@Bean("javaBeanDemo")
	@Lazy
	public JavaBeanDemo userService() {
		return new JavaBeanDemo();
	}
}
